<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	template="/layout/page/sample/left-right-template.xhtml">

	<ui:param name="compId" value="#{commonContentViewBean.id}" />

	<ui:define name="compLeft">
		<h:form id="#{compId}_left_form" style="margin:0;">
		<ui:decorate template="/layout/iteration/tree/sino-tree-single-template.xhtml">
			<ui:param name="compId" value="#{commonContentViewBean.id}_tree" />
			<ui:param name="compViewBean" value="#{commonContentViewBean}" />
			<ui:param name="compSelectedNodeUpdate" value="main-tabSet:#{commonContentViewBean.id}_right_form:#{commonContentViewBean.id}_right_main,main-tabSet:#{commonContentViewBean.id}_right_form:#{commonContentViewBean.id}_right_bread" />
		</ui:decorate>
		</h:form>
	</ui:define>

	<ui:define name="compRight">
		<h:form style="margin:0;" id="#{compId}_right_form">
		<p:toolbar id="#{compId}_right_toolbar" height="30px">
			<p:toolbarGroup align="left" style="margin-left:5px;">
				<p:breadCrumb id="#{compId}_right_bread" style="width:500px;padding:0;border:0 none;background:none repeat scroll 0 0 transparent;">  
				    <c:forEach items="#{commonContentViewBean.currentNodeHiberarchy}" var="node">
				    	<p:menuitem value="#{node.data.name}" onclick="#{compId}_changeCurrentNode('#{compId},#{node.data.id}')" />
				    </c:forEach>
				</p:breadCrumb>
			</p:toolbarGroup>
			
			<p:toolbarGroup align="right">  
				<p:commandButton title="添加部门" value="添加部门" styleClass="portal-toolbar-button" type="button"
					onclick="SinoPortal.View.createWin('org-scene','org-add-and-edit','#{compId}',{'type':'add','displayName':'添加部门'})" />
					
				<p:commandButton title="新建用户" value="新建用户" styleClass="portal-toolbar-button" type="button"
					onclick="SinoPortal.View.createWin('org-scene','user-add-and-edit','#{compId}',{'type':'add','displayName':'添加用户'})" />
				  
				<p:commandButton title="修改" value="修改" styleClass="portal-toolbar-button" type="button"
					onclick="SystemFunc.Org.openOrgEdit('#{compId}')" />
				
				<p:commandButton title="删除" value="删除" styleClass="portal-toolbar-button" type="button"
					onclick="SystemFunc.Org.deleteOrg('#{compId}')" />
				 
			</p:toolbarGroup>
		</p:toolbar>
		
		<h:panelGroup id="#{compId}_right_main" layout="block" style="width:100%;">
			<ul id="#{compId}_right_main" class="portal-dataview-ul">
				<!-- 子组织机构 -->
				<ui:repeat value="#{commonContentViewBean.currentNodeChildren}" var="node">
					<li id="#{compId}_org_#{node.data.id}"
						exdata="#{compId},org,#{node.data.id},#{node.data.name}"
						style="width:100px;height:100px;cursor:pointer;" 
						onmouseover="jQuery(this).addClass('portal-dataview-li-hover')"
						onmouseout="jQuery(this).removeClass('portal-dataview-li-hover')"
						ondblclick="#{compId}_changeCurrentNode('#{compId},#{node.data.id}')"
						onclick="SinoPortal.PageView.dataView.click('#{compId}_right_main',this)"
						class="portal-dataview-li">
						<p:graphicImage value="/img/component/system/org_64.png" style="margin:5px;width:64px;height:64px;" />
						<br />
						<h:outputText value="#{node.data.name}" />
					</li>
				</ui:repeat>
				
				<!-- 当前组织机构的用户集 -->
				<ui:repeat value="#{commonContentViewBean.currentDeptUser}" var="node">
					<li id="#{compId}_user_#{node.data[0]}"
						exdata="#{compId},user,#{node.data[0]},#{node.data[2]}"
						style="width:100px;height:100px;cursor:pointer;" 
						onmouseover="jQuery(this).addClass('portal-dataview-li-hover')"
						onmouseout="jQuery(this).removeClass('portal-dataview-li-hover')"
						onclick="SinoPortal.PageView.dataView.click('#{compId}_right_main',this)"
						class="portal-dataview-li">
						<p:graphicImage value="/img/component/system/user_64.png" style="margin:5px;width:64px;height:64px;" />
						<br />
						<h:outputText value="#{node.data[2]}" />
					</li>
				</ui:repeat>
			</ul>
			
		</h:panelGroup>
		
		<p:remoteCommand name="#{compId}_changeCurrentNode" actionListener="#{orgAction.changeCurrentNode}"
			update="#{compId}_right_main,#{compId}_right_bread">
		</p:remoteCommand>
		
		<p:remoteCommand name="#{compId}_deleteOrg" actionListener="#{orgAction.deleteAction}"
			update="#{compId}_left_form,#{compId}_right_main">
		</p:remoteCommand>
		
		</h:form>
	</ui:define>
</ui:composition>
